# 代码编写者： 李朔
# 开发时间： 2021/9/7 16:00
s='RLRRLLRLRL'
def balancedStringSplit(s):
    frist_len=2
    count=0
    l_p,r_p=0,frist_len
    while r_p<=len(s):
        #字串划分
        s_sub=s[l_p:r_p]
        if s_sub.count("L")==s_sub.count("R"):
            count+=1
            l_p=r_p
            r_p=r_p+2
        else:
            #数量不相同
            r_p=r_p+2
    return count
print(balancedStringSplit(s))

